package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TProTecInfo;
import cn.com.headfree.mouldshow.dao.TProTecInfoDao;
import cn.com.headfree.vo.simple.ProTecInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tProTecInfoDao")
public class TProTecInfoDaoImpl extends BaseDaoImpl<TProTecInfo> implements TProTecInfoDao {


    @Override
    public List<ProTecInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params = new Object[1];
        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.subj_name,t.subj_set,t.subj_level,t.audit_org,t.org_level,t.cert_no,t.acqu_time,u.`NAME` as user_name from t_pro_tec_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.subj_name,GET_DIC('ProTechnicalQualifications',t.subj_set) as subj_set,GET_DIC('ProfessionalQualifications',t.subj_level) as subj_level,t.audit_org,GET_DIC('IdentificationUnitLevel',t.org_level) as org_level,t.cert_no,t.acqu_time,u.`NAME` as user_name from t_pro_tec_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.subj_name,GET_DIC('ProTechnicalQualifications',t.subj_set) as subj_set,GET_DIC('ProfessionalQualifications',t.subj_level) as subj_level,t.audit_org,GET_DIC('IdentificationUnitLevel',t.org_level) as org_level,t.cert_no,t.acqu_time,DATE_FORMAT(t.acqu_time,'%Y-%m-%d %H:%i:%s') as acqu_time_str,u.`NAME` as user_name from t_pro_tec_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.subj_name,GET_DIC('ProTechnicalQualifications',t.subj_set) as subj_set,GET_DIC('ProfessionalQualifications',t.subj_level) as subj_level,t.audit_org,GET_DIC('IdentificationUnitLevel',t.org_level) as org_level,t.cert_no,t.acqu_time,DATE_FORMAT(t.acqu_time,'%Y-%m-%d %H:%i:%s') as acqu_time_str,u.xb_name as user_name from t_pro_tec_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on t.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC;\n");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(ProTecInfoVo.class, sql.toString(), null, false, params);
    }
}
